# -*- coding: utf-8 -*-

import unittest
import os.path

from kivy.lang import Builder

from from_to import FromToWidget
from presenter_mock import PresenterMock
from model.gamestate import *


class FromToTest(unittest.TestCase):
    def setUp(self):
        players = Players([Player('Andrey', []), Player('Boris', []),
                           Player('Charlie', []), Player('Dmitry', [])])
        players.set_next_pair_strategy(TraditionalStrategy(players.players))
        hat = Hat(['стул', 'шапка', 'кастрюлька'])
        game_round = GameRound(20, [], '', (players.players[0],
                                            players.players[2]))
        self.gamestate = GameState(players, hat, game_round,
                                   0, [], None,
                                   Settings(20, 30))
        self.presenter = PresenterMock(Phase.BEFORE_ROUND)

    def test_round_creation_and_button_press(self):
        self.gamestate.game_round = None
        widget = FromToWidget(self.gamestate, self.presenter)
        self.assertEquals(self.presenter.is_phase_changed, False)
        self.assertEquals(self.gamestate.game_round.players_pair,
                          (self.gamestate.players.players[0],
                           self.gamestate.players.players[2]))
        self.assertEquals(self.presenter.is_phase_changed, False)
        widget.finish()
        self.assertEquals(self.presenter.is_phase_changed, True)


if __name__ == '__main__':
    unittest.main()
